export module MyInterface {
    export interface Square {
        kind: 'square';
        width: number;
    }

    export interface Rectangle {
        kind: 'rectangle';
        height: number;
        width: number;
    }
    export type Shape = Square | Rectangle;

    export function calculateArea(shape: Shape) {
        if (shape.kind === 'rectangle') {
            shape;  // Type is Rectangle
            return shape.width * shape.height;
        } else {
            shape;  // Type is Square
            return shape.width * shape.width;
        }
    }
}